package com.yanqu.road.server.cmd.task;


import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.task.ObjectTaskProto;
import com.yanqu.road.pb.task.TaskProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.task.TaskModule;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

@Cmd(code = Protocol.S_OBJECT_TASK_GET_REWARD, desc = "领取任务奖励")
public class GetObjectTaskRewardCmd extends AbstractCommand {
	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ObjectTaskProto.ObjectTaskGetRewardReqMsg reqMsg = ObjectTaskProto.ObjectTaskGetRewardReqMsg.parseFrom(packet.getBytes());
		ret = player.getModule(TaskModule.class).getObjectTaskReward(reqMsg);
	}

	@Override
	public void sendData(GamePlayer player) {
		if (ret > 0) {
			player.sendPacket(Protocol.S_OBJECT_TASK_GET_REWARD % 20000, TaskProto.TaskGetRewardRespMsg.newBuilder().setRet(ret));
		}
	}

}
